using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Etna.Exportaciones.En;
using Etna.Exportaciones.Ad;

namespace Etna.Exportaciones.Rn
{
   public class RnPackingList:RnGeneral
   {
      public EnPackingList Leer(int pidPakingList)
      {
         EnPackingList oEnPackingList = null;

         using (SqlConnection con = new SqlConnection(CadenaConexion))
         {
            try
            {
               con.Open();
               AdPackingList oAdPackingList = new AdPackingList();
               oEnPackingList = oAdPackingList.Leer(pidPakingList, con);
            }
            catch (SqlException ex)
            {
               oEnPackingList = null;
            }
         }
         return oEnPackingList;
      }

      // Proceso para insertar un registro nuevo
      public bool Insertar(EnPackingList poEnPackingList)
      {
          bool Resultado = false;

          using (SqlConnection con = new SqlConnection(CadenaConexion))
          {

             try
              {
                  con.Open();
                  AdPackingList oAdPackingList = new AdPackingList();
                  Resultado = oAdPackingList.Insertar(poEnPackingList, con);
              }
              catch (SqlException ex)
              {
                  Resultado = false;
              }
          }
          return Resultado;
      }
      // Proceso para modificar un registro existente
      public bool Modificar(EnPackingList poEnPackingList)
      {
          bool Resultado = false;

          using (SqlConnection con = new SqlConnection(CadenaConexion))
          {

             try
              {
                  con.Open();
                  AdPackingList oAdPackingList = new AdPackingList();
                  Resultado = oAdPackingList.Modificar(poEnPackingList, con);
              }
              catch (SqlException ex)
              {
                  Resultado = false;
              }
          }
          return Resultado;
      }
      public List<EnPackingList> Listar(int pidPakingList)
      {
         List<EnPackingList> loEnPackingList = null;

         using (SqlConnection con = new SqlConnection(CadenaConexion))
         {
            try
            {
               con.Open();
               AdPackingList oAdPackingList = new AdPackingList();
               loEnPackingList = oAdPackingList.Listar(pidPakingList, con);
            }
            catch (SqlException ex)
            {
               loEnPackingList = null;
            }
         }
         return loEnPackingList;
      }

   }
}
